package com.lemner.ke.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.lemner.ke.R;

/**
 * 自定义MyDialog
 * @author raintea
 * @date 2018/10/11
 */
public class MyDialog extends Dialog {
    private Context context;
    private String title;
    private String confirmButtonText = "确定";
    private String cacelButtonText = "取消";
    private TextView tv_title, tv_confirm, tv_cancel;

    public MyDialog(@NonNull Context context,String title) {
        super(context,R.style.Dialog);
        this.context=context;
        this.title=title;
        init();
    }
    private void init() {
        setContentView(LayoutInflater.from(context).inflate(R.layout.dialog_base, null));
        tv_title = findViewById(R.id.tv_dialog_title);
        tv_confirm = findViewById(R.id.tv_dialog_confirm);
        tv_cancel = findViewById(R.id.tv_dialog_cancel);
        tv_title.setText(title);
        tv_confirm.setText(confirmButtonText);
        tv_cancel.setText(cacelButtonText);

        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
    public void setOnConfirmClickListener(View.OnClickListener onClickListener) {
        tv_confirm.setOnClickListener(onClickListener);
    }
}
